﻿namespace CardGames
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    public class Card : IComparable<Card>
    {
        public Suits Suit  { get; set; }
        public CardValues Value { get; set; }

        public Card(Suits suit, CardValues value)
        {
            if (suit == Suits.Joker && value != CardValues.Wild)
            {
                throw new ArgumentException();
            }

            this.Suit = suit;
            this.Value = value;
        }

        public string Name
        {
            get 
            {
                if (this.Suit == Suits.Joker)
                {
                    return this.Suit.ToString();
                }
                return String.Format("{0} of {1}",this.Value.ToString(),this.Suit.ToString()); 
            }
        }

        public int CompareTo(Card cardToCompare)
        {
            if (this.Value > cardToCompare.Value)
            {
                return 1;
            }
            else if (this.Value < cardToCompare.Value)
            {
                return -1;
            }
            else
            {
                return 0;
            }
        }
    }
}
